//class made by Teo ( www.teodorfilimon.com ). More about the app in readme.txt

package com.teo.tools.counter;

import android.app.Dialog;
import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;

/**
 * A class that contains some helper functions
 */
final class Utils {

	/**
	 * A general usage function, usable from any activity. It shows a dialog
	 * with a text message, and is compatible with both landscape and portrait
	 * mode because of the contained ScrollView.
	 * 
	 * @param titleId
	 *            resource id of the title string
	 * @param messageId
	 *            resource id of the message string
	 * @param c
	 *            context passed to the UI constructors
	 */
	public final static void showDialog(int titleId, int messageId, Context c) {
		final Dialog d = new Dialog(c);
		ScrollView sv = new ScrollView(c);
		TextView tv = new TextView(c);
		sv.addView(tv);
		LinearLayout ll = new LinearLayout(c);
		ll.setOrientation(1);
		tv.setTextSize(18);
		tv.setText(messageId);
		final Button b = new Button(c);
		b.setText(R.string.go_back);
		b.setOnClickListener(new View.OnClickListener() {
			public void onClick(View view) {
				d.dismiss();
			}
		});
		ll.setPadding(10, 10, 10, 0);
		ll.addView(b);
		ll.addView(sv);
		if (titleId > -1) {
			d.setTitle(titleId);
		} else {
			d.setTitle("");
		}
		d.setContentView(ll);
		d.show();
	}
}